<?php
namespace Admin\Controller;
//意见反馈

use Common\Controller\AdminbaseController;

class FeedbackController extends AdminbaseController{

	protected $feedback_model;

	public function _initialize() {
		parent::_initialize();
		$this->feedback_model = M('feedback');
	}

	// 意见反馈列表
	public function index(){
		/**搜索条件**/
        $feedback_content = I('request.feedback_content');
        $create_member = I('request.create_member');

		if($feedback_content){
			$where['feedback_content'] = array('like',"%$feedback_content%");
		}

		if($create_member){
			$where['create_member'] = array('like',"%$create_member%");
		}

		$count=$this->feedback_model->where($where)->count();
		$page = $this->page($count, 10);
        $list = $this->feedback_model
            ->where($where)
            ->order("id DESC")
            ->limit($page->firstRow, $page->listRows)
            ->select();
		$this->assign("page", $page->show('Admin'));
        $this->assign('list',$list);
		$this->display();
	}


    public function excelout()
    {
        /**搜索条件**/
        $feedback_content = I('request.feedback_content');
        $create_member = I('request.create_member');

        if($feedback_content){
            $where['feedback_content'] = array('like',"%$feedback_content%");
        }

        if($create_member){
            $where['create_member'] = array('like',"%$create_member%");
        }

        $data = $this->feedback_model->where($where)->order('create_time desc')->select(); //查出数据
        if(empty($data)){
            $this->error('没有记录，无法导出');die();
        }
        $xlsName="意见反馈列表";//文件名
        $xlsCell=array(
                    array('id','ID'),
                    array('feedback_content','反馈内容'),
                    array('create_member','创建用户'),
                    array('create_time','创建时间')
                );
        exportExcel($xlsName,$xlsCell,$data);
        die();
    }

}